package ch15;

import java.util.Scanner;

/**
 * Created by 春旺 on 2017/10/17.
 */
public class YangHui {
    public static void main(String[] args) {
        // 初始化队列
        CircularArrayQueue queue = new CircularArrayQueue();
        //加入第一行
        queue.enqueue(0);
        queue.enqueue(1);
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入想要显示行数：");
        int n = scan.nextInt();
        int a=0,b= 0,c;
        // 打印第一行
        for (int i = 0;i< n-(queue.size()-2);i++){
            System.out.print(" ");
        }
        System.out.println(1);
        for (int i = 1;i<= n - 1; i++){
            queue.enqueue(0);
            for (int bi = 0;bi< n-(queue.size()-2);bi++){
                System.out.print(" ");
            }

            for (int ai =1;ai< queue.size();ai++){
                a= (int) queue.first();
                queue.dequeue();
                b = (int) queue.first();
               c = a+b;
               queue.enqueue(c);
               System.out.print(c + " ");
            }
          System.out.println();
        }
    }



}
